package cn.levi.path.annotation;

import cn.levi.path.component.URLPathHandler;
import cn.levi.path.config.FilePathDeserialize;
import cn.levi.path.config.FilePathSerializer;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 该注解用于向前端返回文件路径时，自动拼接上前缀和鉴权处理
 * @author lei
 * @since 2024/9/6
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@JacksonAnnotationsInside
@JsonSerialize(using = FilePathSerializer.class)
@JsonDeserialize(using = FilePathDeserialize.class)
public @interface FilePathAuto {

	/**
	 * 文件前缀,序列化时有效，如果配置，则默认调用{@link URLPathHandler#concatUrlPrefix(String)}方法获取最终访问地址
	 */
	String host() default "";


}
